package cn.rxls.community.controller;


import cn.rxls.community.dto.orders.OrdersDetailCategoryDTO;
import cn.rxls.community.dto.orders.OrdersPageCategoryDTO;
import cn.rxls.community.result.Result;
import cn.rxls.community.service.OrdersService;
import cn.rxls.community.vo.orders.OrdersVO;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;


/**
 * 订单(Orders)表
 *
 */
@RestController
@RequestMapping("orders")
public class OrdersController {
    /**
     * 服务对象
     */
    @Resource
    private OrdersService ordersService;

    /**
     * 根据状态分页查询
     * @param dto 参数对象
     * @return 多条订单数据
     */
    @GetMapping("/page/category")
    public Result<List<OrdersVO>> selectPageByCategory(@ModelAttribute OrdersPageCategoryDTO dto){
        return Result.success(ordersService.selectPageByCategory(dto));
    }


    /**
     * 根据类型、id查询订单详情
     * @param dto 参数对象
     * @return 单条订单数据
     */
    @GetMapping("/category/detail")
    public Result<Object> selectPageByCategory(@ModelAttribute OrdersDetailCategoryDTO dto){
        return Result.success(ordersService.selectDetailByCategoryAndId(dto));
    }

}

